//TESH.scrollpos=0
//TESH.alwaysfold=0
<?local slk = require 'slk' ?>
library EquitPoolSystem initializer Init
    globals
        integer UnusedCount
        integer array UnusedEquitTypePool
    endglobals
    

    function ReturnEquitType takes item i returns nothing
        set UnusedEquitTypePool[UnusedCount] = GetItemTypeId(i)
        set UnusedCount = UnusedCount + 1
    endfunction
    
    function GetEquitTypeId takes nothing returns integer
        local integer et = 0
        set UnusedCount = UnusedCount -1
        if UnusedCount<0 then
            set UnusedCount = 0
        else
            set et = UnusedEquitTypePool[UnusedCount]
            set UnusedEquitTypePool[UnusedCount] = 0
        endif
        return  et
    endfunction
    
    
    private function Init takes nothing returns nothing
    <? 
        local count = 1000
        for i = 1, count do
            local eobj = slk.item.afac:new("实体物品."..i)
            eobj.Name = string.format("实体物品[%03d]", i)
            eobj.abilList = ""
            eobj.Description = ""
            eobj.Level = 0
            eobj.oldLevel = 0
            eobj.goldcost = 0
            eobj.HP = 1000000000
            eobj.cooldownId = ""
    ?>
            set UnusedEquitTypePool[<?=(i-1)?>]='<?=eobj:get_id()?>'
    <?
        end
    ?>
    set UnusedCount = <?=count?>
    endfunction
endlibrary
